//package com.demo.ai.config;
//
//import org.springframework.ai.chat.model.aggregator.MessageAggregator;
//import org.springframework.ai.chat.model.transformer.ChatResponseTransformer;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import java.time.Duration;
//import com.fasterxml.jackson.databind.DeserializationFeature;
//import com.fasterxml.jackson.databind.ObjectMapper;
//
//@Configuration
//public class AiConfig {
//
//    /**
//     * 流式响应聚合超时时间依赖
//     * @return
//     */
//    @Bean
//    public MessageAggregator messageAggregator() {
//        // 设置30秒超时和宽松的JSON解析
//        return new MessageAggregator(
//                Duration.ofSeconds(30),
//                new ObjectMapper()
//                        .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
//        );
//    }
//
//    @Bean
//    public ChatResponseTransformer chatResponseTransformer() {
//        return new ChatResponseTransformer(messageAggregator());
//    }
//}